﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace JGSY.CourseManagement.Infrastructure.Data.Migrations.SqlServerMigrations
{
    /// <inheritdoc />
    public partial class InitialCreate_V1 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Courses",
                columns: table => new
                {
                    CourseId = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    CourseName = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: false),
                    Description = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
                    IsPublish = table.Column<int>(type: "int", nullable: false),
                    CourseCover = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
                    CourseUrl = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Courses", x => x.CourseId);
                });

            migrationBuilder.CreateTable(
                name: "CourseTeacherRelations",
                columns: table => new
                {
                    CourseId = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    TeacherId = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CourseTeacherRelations", x => new { x.CourseId, x.TeacherId });
                });

            migrationBuilder.CreateTable(
                name: "Platforms",
                columns: table => new
                {
                    PlatformId = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    PlatformName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    IsValidation = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Platforms", x => x.PlatformId);
                });

            migrationBuilder.CreateTable(
                name: "PlayRecords",
                columns: table => new
                {
                    CourseId = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    PlatformId = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    PlayCount = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
                    IsGrowing = table.Column<int>(type: "int", nullable: false),
                    GrowingRate = table.Column<decimal>(type: "decimal(18,2)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PlayRecords", x => new { x.CourseId, x.PlatformId });
                });

            migrationBuilder.CreateTable(
                name: "Users",
                columns: table => new
                {
                    UserId = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    UserName = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    RealName = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    Password = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
                    IsValidation = table.Column<int>(type: "int", nullable: false),
                    IsCanLogin = table.Column<int>(type: "int", nullable: false),
                    IsTeacher = table.Column<int>(type: "int", nullable: false),
                    Avatar = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    Gender = table.Column<int>(type: "int", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Users", x => x.UserId);
                });
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Courses");

            migrationBuilder.DropTable(
                name: "CourseTeacherRelations");

            migrationBuilder.DropTable(
                name: "Platforms");

            migrationBuilder.DropTable(
                name: "PlayRecords");

            migrationBuilder.DropTable(
                name: "Users");
        }
    }
}
